<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../../../assets/libs/jquery/jquery-3.6.1.min.js"></script>
</head>

<body>
  <img src="https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png" data-my-attr="张智琦">

  <script>
    // 获取、设置内置属性和自定义属性
    console.log($('img').attr('src'))
    $('img').attr('src', 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png')
    console.log($('img').attr('data-my-attr'))
    $('img').attr('data-my-attr', '张智琦2')

    // 获取、设置内置属性
    console.log($('img').prop('src'))
    $('img').prop('src', '../../../../assets/images/Cheems.jpg')

    // 获取自定义属性
    console.log($('img').data('my-attr'))
  </script>
</body>

</html>